const fs = require('fs')
const msg = 'hello'
const msgCN = '我聪明'

let buffer = new Buffer(msg)
// console.log(buffer);


const buffer2 = Buffer.from(msg)
console.log(buffer2);

const buffer3 = Buffer.alloc(3)
// ---<Buffer 00 00 00>
buffer3[0] = 0x88
// ---<Buffer 88 00 00>
console.log(buffer3)

const bufferCN = Buffer.from(msgCN,'utf-8')
// console.log(bufferCN.toString());



// 读取文本文件
fs.readFile("./buffer.txt", (err, data) => {
  console.log(data);
  console.log(data.toString());
});

读取图片文件
fs.readFile("./bar.png", (err, data) => {
  console.log(data);

  fs.writeFile("./foo.png", data, err => {
    console.log(err);
  });
});



// sharp库的使用
// sharp('./bar.png')
//   .resize(200, 200)
//   .toFile('./baz.png');
